# 元组是不可变序列，没有增删改查操作
# 可索引获取，可遍历
# tp = ('hello', [1, 2, 3], '小红', 'Java')
# print(tp)
#
# tp = tuple('helloworld')
# print(tp)
#
# tp = tuple([10,20,30,50])
# print(tp)

# print(10 in tp)
# print(10 not in tp)
# print(max(tp))
# print(min(tp))
# print(len(tp))
# print(tp.index(10))
# print(tp.count(10))
#
# # 只有一个元素时，逗号不能省略
# t = (123,)
# print(t,type(t))
# del t
# print(t)

# # 切片
# t2 = tp[0:3:2]
# print(t2)
#
# # 遍历
# for item in tp:
#     print(item)
# print('-' * 40)
#
# for i in range(len(tp)):
#     print(i, tp[i])
# print('-' * 40)
#
# for index, item in enumerate(tp, start=1):
#     print(index, item)
# print('-' * 40)

# 生成式的结果是一个生成式对象
# t = (i for i in range(1, 4))
# print(t)
# 需要转换成元组，才可以看到元素内容
# t = tuple(t)
# print(t)
# for item in t:
#     print(item)
# 元素可以通过__next__()获取
# print(t.__next__())
# print(t.__next__())
# print(t.__next__())
#
# t = tuple(t)
# print(t)